﻿using Crawler.DBEntities;
using Crawler.WebEntities;
using System;
using System.Collections.Generic;
using System.Text;

namespace Crawler.DataHelper
{

    public static class ForumHelper
    {
        /// <summary>
        ///判断表中是否存在该记录
        /// </summary>
        /// <param name="uri"></param>
        /// <returns></returns>
        public static bool IsFromExist(MyUri uri)
        {
            MysqlHelper helper = new MysqlHelper();
            return helper.IsForumExist(uri);
        }
        /// <summary>
        /// 设置forum的信息
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="forum"></param>
        /// <returns></returns>
        public static bool SetForumInfo(MyUri uri, ref Forum forum)
        {
            bool isSetSucceed = true;
            try
            {
                forum.Url = uri.AbsoluteUri;
                forum.Seed_forum_id = uri.Fk_seed;
                forum.CreateTime = DateTime.Now;
            }
            catch (Exception)
            {
                isSetSucceed = false;
            }
            return isSetSucceed;
        }
        public static bool UpdateForum(ref MyUri uri, Forum forum)
        {
            MysqlHelper helper = new MysqlHelper();
            return helper.UpdateForum(ref uri, forum);
        }
        public static bool InsertForum(ref MyUri uri, Forum forum)
        {
            MysqlHelper helper = new MysqlHelper();
            return helper.InsertForum(ref uri, forum);
        }
    }
}


